using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace ERPBackend.Models
{
    public class PurchaseReceiptItem : BaseModel
    {
        [Required]
        public int PurchaseReceiptId { get; set; }

        [Required]
        public int LineNumber { get; set; }

        [ForeignKey("PurchaseReceiptId")]
        public PurchaseReceipt? PurchaseReceipt { get; set; }

        public int? PurchaseOrderItemId { get; set; }

        [ForeignKey("PurchaseOrderItemId")]
        public PurchaseOrderItem? PurchaseOrderItem { get; set; }

        [Required]
        public int MaterialId { get; set; }

        [ForeignKey("MaterialId")]
        public Material? Material { get; set; }

        [Required]
        [StringLength(255)]
        public string MaterialName { get; set; } = string.Empty;

        [StringLength(255)]
        public string? Specification { get; set; }

        [Required]
        [StringLength(50)]
        public string Unit { get; set; } = string.Empty;

        [Required]
        [Column(TypeName = "decimal(18, 4)")]
        public decimal PurchaseQuantity { get; set; } = 0;

        [Required]
        [Column(TypeName = "decimal(18, 4)")]
        public decimal ReceiptQuantity { get; set; } = 0;

        [Column(TypeName = "decimal(18, 4)")]
        public decimal QualifiedQuantity { get; set; } = 0;

        [Column(TypeName = "decimal(18, 4)")]
        public decimal UnqualifiedQuantity { get; set; } = 0;

        [Column(TypeName = "decimal(18, 4)")]
        public decimal StockInQuantity { get; set; } = 0;

        [StringLength(255)]
        public string? UnqualifiedReason { get; set; }

        [StringLength(500)]
        public string? Remark { get; set; }
    }
}